package com.onpositive.funkytable.impl;

import com.onpositive.funkytable.IFunkyControl;
import com.onpositive.funkytable.IFunkyTextControl;
import com.onpositive.funkytable.ILayoutParams;
import com.onpositive.funkytable.Point;

public class LabelAndValue {

	public LabelAndValue(IFunkyTextControl label, IFunkyControl value) {
		super();
		this.label = label;
		this.value = value;
		measureL = label != null ? label.measure(ILayoutParams.WRAP_WIDTH,
				ILayoutParams.WRAP_WIDTH) : new Point(0, 0);
		measureT = value.measure(ILayoutParams.WRAP_WIDTH,
				ILayoutParams.WRAP_WIDTH);
	}

	public final IFunkyTextControl label;
	public final IFunkyControl value;

	public final Point measureL;
	public final Point measureT;

	public double fillRateHorizontal(int width) {
		int i = measureL.x + measureT.x;
		if (i > width) {
			return -1;
		}
		return (((double) i) / width);
	}
	
	public double fillRateVertical(int width) {
		int i = Math.max(measureL.x , measureT.x);
		if (i > width) {
			return -1;
		}
		return (((double) i) / width);
	}
}
